#ifndef BOOT_LOADER_H
#define BOOT_LOADER_H
#include <vector>
#include <string>
#include "libusb.h"
class BootLoader
{
public:
	enum IapStatus
	{
		IAP_START = 0,
		START_ACK,
		IAP_SEND_DATA,
		DATA_ACK,
		IAP_MD5,
		MD5_ACK,
		IAP_END,
		END_ACK,
		IAP_IDLE,
		IAP_WAIT_ACK,
		IAP_TIMEOUT
	};
	BootLoader();
	~BootLoader();
	bool Init();
	std::vector<std::string> USBListDevice();
	void Deinit();
	void IapUpdate(const char*);
	void IapGet(const char*);
	bool IsOpen()
	{
		return open_flag_;
	}
	void StartDebugThread();
private:
	void internal_recv_debug();
	libusb_device **devs_;
	libusb_device_handle *dev_handle_;
	libusb_context *ctx_;
	struct  libusb_device_descriptor desc_;
	uint8_t		process_;
	int			transfer_bytes_;
	int			total_bytes_;
	IapStatus	iap_sta_;
	int64_t     timetick_;
	bool		open_flag_;
};
#endif

